import request from '@/utils/request'
// 得到商品列表
export const getSpuList = (page, limit, category3Id) => {
  return request({
    url: `/admin/product/${page}/${limit}`,
    method: 'get',
    params: {
      category3Id
    }
  })
}
// 获取平台中全部的销售属性
export const getTradeMarkList = () => {
  return request({
    url: '/admin/product/baseTrademark/getTrademarkList',
    method: 'get'
  })
}
// 获取某一个spu信息
export const getSpuInfoById = (spuId) => {
  return request({
    url: `/admin/product/getSpuById/${spuId}`,
    method: 'get'
  })
}
// 获取spu图片
export const getSpuImage = (spuId) => {
  return request({
    url: `admin/product/spuImageList/${spuId}`,
    method: 'get'
  })
}
// 获取全部销售属性
export const getBaseSaleAttr = () => {
  return request({
    url: `admin/product/baseSaleAttrList`,
    method: 'get'
  })
}
// 添加或者修改spu
export const addOrUpdateSpu = (spuInfo) => {
  if (spuInfo.id) {
    return request({
      url: '/admin/product/updateSpuInfo',
      method: 'post',
      data: spuInfo
    })
  } else {
    return request({
      url: '/admin/product/saveSpuInfo',
      method: 'post',
      data: spuInfo
    })
  }
}
// 删除spu
export const deleteSpu = (spuId) => {
  console.log(spuId)
  return request({
    url: `/admin/product/deleteSpu/${spuId}`,
    method: 'delete'
  })
}
// 获取sku列表
export const getSkuList = (spuId) => {
  return request({
    url: `/admin/product/findBySpuId/${spuId}`,
    method: 'get'
  })
}
